<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>methods</title>
    <!--引入Vue库-->
    <script src="vue.js"></script>
  </head>
  <body>
    <script>
      var vm = new Vue({
        data: { x: 2 },
        methods: {
          plus: function () {
            this.x++;
          },
        },
      });
      vm.plus();
      console.log(vm.x); // 3
    </script>
  </body>
</html>
